package com.xiyuan.smartutils.client.ws.core.auth;

import com.xiyuan.smartutils.client.http.HttpHeader;
import com.xiyuan.smartutils.client.ws.WebSocket;
import com.xiyuan.smartutils.client.exception.WebSocketException;

/**
 * The Interface of ProxyCredentials.
 *
 * @author xiyuan-lgz
 */
public interface Authenticator {
    
    /**
     * Gets the credentials.
     *
     * @param method request method GET,POST,CONNECT(proxy)
     * @param requestUri the request uri
     * @param header http header
     * @param authenticateHeaderName the authenticate header name
     * @return the credentials
     * @throws WebSocketException the web socket exception
     */
    public String getCredentials(String method, String requestUri, HttpHeader header, String authenticateHeaderName) throws WebSocketException;
    /**
     * inits authenticator
     *
     * @param websocket the websocket
     * @param credentials the credentials
     */
    public void init(WebSocket websocket, Credentials credentials);

    /**
     * finish authenticate phase.
     * if retry authenticate, need to create a new Authenticator instance.
     */
    public void done();

    public boolean isNeedAuthenticate();

    public boolean isDone();
}
